# -*- coding:utf-8 -*-
# @Author: shenyuyu
# @Time: 2023/6/28 10:34
# @File: qu_1_spark_sql.py
from pyspark.sql import SparkSession

if __name__ == '__main__':
    spark = SparkSession.builder.appName("a").master("local[*]").getOrCreate()
    sc = spark.sparkContext
    df = spark.read.csv("file:///tmp/pycharm_project_161/data/sql/stu_score.txt", sep=",", header=False)
    df = df.toDF("id", "subject", "score")
    df.printSchema()
    df.show()

    df.createOrReplaceTempView("score")

    spark.sql("select * from score where subject = '语文'").show()

    df.where("subject = '语文'").show()